<?php
namespace App\Store\Services\Goods;

class GoodsReplenishService
{

    /**
     * 补货的总成本计算
     * @param $data
     * @param $is_gram
     * @return float[]|int[]
     */
    public function replenishTotalCost($data,$is_gram)
    {
        //补货金价
        $repllennish_costglod_price =$data['repllennish_costglod_price']??0;
        //补货总金重
        $total_netglod_weight =$data['total_netglod_weight']??0;
        //补货的金重
        $netglod_weight =$data['netglod_weight']??0;
        $count =$data['count']??0;

        //$is_gram 是否克算，1是，2否
        if($is_gram==1){
            //补货时的单件成本=0
            // 补货时的总成本=补货总金重*补货金价
            $total_cost_fee = $total_netglod_weight*$repllennish_costglod_price;
            $piececost_fee=0;
        }else{
            //补货时的单件成本=补货的金重*补货金价
            $piececost_fee =$netglod_weight*$repllennish_costglod_price;
            // 补货时的总成本=补货件数*补货时的单件成本
            $total_cost_fee = $count*$piececost_fee;
        }

        return [$piececost_fee,$total_cost_fee];
    }
}
